package pers.zhang.util;

import com.alibaba.fastjson.JSONObject;
import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
import org.apache.http.client.HttpClient;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.impl.client.DefaultHttpClient;
import org.apache.http.impl.client.HttpClientBuilder;
import org.apache.http.impl.conn.DefaultHttpClientConnectionOperator;
import org.apache.http.util.EntityUtils;
import sun.net.httpserver.DefaultHttpServerProvider;

import javax.swing.text.html.parser.Entity;
import java.io.IOException;

/**
 * @Classname WeXinUtil
 * @Description TODO
 * @Date 2019/1/15 14:19
 * @Created by zhangkai
 */
public class WeXinUtil {
    public  static final  String APPID="wx70d9e9d19458c583";
    public  static final  String APPSECRET="c95ca608d734742e1963941abbba9c65";
    public static JSONObject doGetJson(String url) throws IOException {
        JSONObject jsonObject=null;
        HttpClient client=HttpClientBuilder.create().build();
        HttpGet httpGet=new HttpGet(url);
        HttpResponse response=client.execute(httpGet);
        HttpEntity entity=response.getEntity();
        if (entity !=null)
        {
            String result=EntityUtils.toString(entity,"UTF-8");
            jsonObject=JSONObject.parseObject(result);
        }
        httpGet.releaseConnection();
       return    jsonObject;
    }
}
